<%@page import="entity.News"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'newslist.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
		function del(id){
			if(confirm("确定删除？？")){
				location.href="Dle?id="+id;
			}
		}
	</script>

  </head>
  
  <body>
    This is my JSP page. <br>
    <table border="1" width="100%">
    	<thead>
    		<tr>
    			<td>编号</td><td>标题</td><td>作者</td><td>内容</td>
    			<td>发布时间</td><td>数据操作</td>
    		</tr>
    	</thead>
    <%List list=(List)session.getAttribute("list");
    if(list.size()==0){
    %>
    <tr>
    <td colspan="5"><h1>很遗憾！数据库中没有任何新闻。</h1></td>
    </tr>
    <%	
    }else{
    	Iterator iter=list.iterator();
    	while(iter.hasNext()){
    		News news=(News)iter.next();
    %>
   			<tr>
   			<td><%=news.getNid()%></td><td><%=news.getNtitle()%></td>
   			<td><%=news.getNauthor()%></td><td><%=news.getNtext()%></td>
   			<td><%=news.getNcreatedate()%></td><td><a href="javascript:del(<%=news.getNid()%>)">删除</a> </td>
   			</tr> 	    	
    <% 		
    	}
    }
    %>
    </table>
  </body>
</html>
